//
//  ContentView.swift
//  GoCash
//
//  Created by jie on 2024/4/30.
//

import SwiftUI

struct ContentView: View {
    
    @State var isNext: Bool = false
    
    var body: some View {
        
        NavigationView(content: {
            VStack(content: {
                let width = UIScreen.main.bounds.size.width
                let itemWidth = (width-50)/4.0
                HStack(alignment: .top, spacing: 10, content: {
                    
                    
                    RoundedRectangle(cornerRadius: 4).foregroundColor(.green).frame(height: itemWidth).padding(.leading, 10)
                    RoundedRectangle(cornerRadius: 4).foregroundColor(.green).frame(height: itemWidth).padding(0)
                    RoundedRectangle(cornerRadius: 4).foregroundColor(.green).frame(height: itemWidth).padding(0)
                    RoundedRectangle(cornerRadius: 4).foregroundColor(.green).frame(height: itemWidth).padding(.trailing, 10)
                }).padding(.top, 10).background(.white)
                
                HStack(alignment: .top, content: {
                    RoundedRectangle(cornerRadius: 4).foregroundColor(.red).frame(width: itemWidth, height: 80).padding(0)
                    NavigationLink(destination: HomePage()) {
                        ZStack {
                            Rectangle().foregroundColor(.blue).opacity(0.8).frame(width: itemWidth*2, height: 80).padding(0).cornerRadius(4)
                            Text("导航到下一个页面").foregroundColor(.white)
                        }
                    }
                    Spacer()
                }).padding(EdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10))
                Spacer()
            })
            .navigationBarItems(leading: EmptyView())
            .navigationTitle("我是导航栏标题")
            .navigationBarTitleDisplayMode(.inline)
            .foregroundColor(.white)
            .navigationBarUIColor(.blue)
        })
        .onAppear() {
            
        }
        .onDisappear() {
            
        }
        
    }
}

#Preview {
    ContentView()
}



//import SwiftUI
// 
//struct ContentView: View {
//    @State private var isPresented = false
// 
//    var body: some View {
//        VStack {
//            Button("Pop to Root") {
//                isPresented.toggle()
//            }
//            .padding()
//        }
//        .navigationBarTitle("Detail View")
//        
//    }
//}
// 
//struct RootView1: View {
//    var body: some View {
//        NavigationView {
//            VStack {
//                NavigationLink(destination: ContentView()) {
//                    Text("Push to Detail View")
//                }
//            }
//            .navigationBarTitle("Root View")
//        }
//    }
//}
// 
//extension View {
//    func popToRoot(isPresented: Binding<Bool>) -> some View {
//        background(
//            EmptyView().popToRoot(isPresented: isPresented)
//        )
//    }
//}
//
//
//#Preview{
//    RootView1()
//}
